package
{
	import flash.utils.getDefinitionByName;

	public class Serializer
	{
		public function Serializer()
		{
		}
		
		public static function serializeArray(array:Array):Array{
			var i:int, length:int;
			var serialized:Array = new Array();
			length = array.length;
			for(i = 0; i < length; i++){
				serialized.push(array[i].serialize());
			}
			
			return serialized;
		}
		
		public static function wakeupArray(classType:String, serDatas:Array, array:Array):void{
			var i:int, length:int;
			length = serDatas.length;
			for(i = 0; i < length; i++){
				var classReference:Class = getDefinitionByName(classType) as Class;
				var serializable:ISerializable = (new classReference) as ISerializable;
				serializable.wakeup(serDatas[i]);
				array.push(classReference);
			}
		}
	}
}